<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">

<title>class OpenSSL::ASN1::ASN1Data - openssl: Ruby Standard Library Documentation</title>


<script src="../../js/navigation.js" defer></script>
<script src="../../js/search.js" defer></script>
<script src="../../js/search_index.js" defer></script>
<script src="../../js/searcher.js" defer></script>
<script src="../../js/darkfish.js" defer></script>

<script src="../../js/jquery-3.2.0.min.js"></script>

<script src="../../js/vue.min.js"></script>
<script src="../../js/js.cookie.min.js"></script>

<link href="../../css/fonts.css" rel="stylesheet">
<link id='rdoccss' href="../../css/rdoc.css" rel="stylesheet">
<link href="../../css/carbon17.css" rel="stylesheet">

<script type="text/javascript">
  var rdoc_rel_prefix = "../../";
  var index_rel_prefix = "../../";
  var darkModeCsseHref = "../../css/rdoc-dm.css"
  var defaultModeCssHref = "../../css/rdoc.css"
  // var cssDarkmode = Cookies.get('darkmode');
  
  if( Cookies.get("darkmode") == "true") {
	$('#rdoccss').attr("href", darkModeCsseHref);
}

//  https://cssdeck.com/blog/simple-jquery-stylesheet-switcher/

document.write('<style type="text/css">body{display:none}</style>');

</script>


</head>
<body id="top" role="document" class="class">
  <!-- this is class.html -->

  <div id='actionbar' >
    <div class='wrapper mdiv'>
      <ul class='grids g0'></ul>
    </div> 
    <!-- VERSION HEADER for 3.3.0.preview2 NOT FOUND -->
  </div> <!-- end action bar -->

  <div class='wrapper hdiv'>

    


    <nav id='vapp' role="navigation">
    <div id="project-navigation">
      <div id="home-section" role="region" title="Quick navigation" class="nav-section">
  <h2><a href="../../index.html" rel="home">Home</a></h2>

  <div id="table-of-contents-navigation"  >
    <a href="../../table_of_contents.html#pages">Pages</a>
    <a href="../../table_of_contents.html#classes">Classes</a>
    <a href="../../table_of_contents.html#methods">Methods</a>
  </div>
</div>

      <div id="search-section" role="search" class="project-section initially-hidden">
  <form action="#" method="get" accept-charset="utf-8">
    <div id="search-field-wrapper">
      <input id="search-field" role="combobox" aria-label="Search"
             aria-autocomplete="list" aria-controls="search-results"
             type="text" name="search" placeholder="Search" spellcheck="false"
             title="Type to search, Up and Down to navigate, Enter to load">
    </div>

    <ul id="search-results" aria-label="Search Results"
        aria-busy="false" aria-expanded="false"
        aria-atomic="false" class="initially-hidden"></ul>
  </form>
</div>

    </div>


    
<div class="nav-section">
  <h3>Table of Contents</h3>

  <ul class="link-list" role="directory">
    <li><a href="#class-OpenSSL::ASN1::ASN1Data-label-The+role+of+ASN1Data+for+parsing+tagged+values">The role of ASN1Data for parsing tagged values</a>
    <li><a href="#class-OpenSSL::ASN1::ASN1Data-label-Example+of+a+parsed+implicitly+tagged+value">Example of a parsed implicitly tagged value</a>
    <li><a href="#class-OpenSSL::ASN1::ASN1Data-label-Example+of+a+parsed+explicitly+tagged+value">Example of a parsed explicitly tagged value</a>
    <li><a href="#class-OpenSSL::ASN1::ASN1Data-label-Example+-+Decoding+an+implicitly+tagged+INTEGER">Example - Decoding an implicitly tagged INTEGER</a>
    <li><a href="#class-OpenSSL::ASN1::ASN1Data-label-Example+-+Decoding+an+explicitly+tagged+INTEGER">Example - Decoding an explicitly tagged INTEGER</a>
  </ul>
</div>


    <button id='toggleThing' @click="toggleNav()" >Show/hide navigation</button>
    <div :class="isOpen ? 'block' : 'hidden' " id='toggleMe'>
      <div id="class-metadata">
        
        
<div id="parent-class-section" class="nav-section">
  <h3>Parent</h3>

  <p class="link">Object
</div>

        
        
        
<!-- Method Quickref -->
<div id="method-list-section" class="nav-section">
  <h3>Methods</h3>

  <ul class="link-list" role="directory">
    <li ><a href="#method-c-new">::new</a>
    <li ><a href="#method-i-to_der">#to_der</a>
  </ul>
</div>

      </div>
     </div>
    </nav>


    <div id='extraz'><div class='adzbox-index'  >
      
     </div>         
    </div>

    <main role="main" aria-labelledby="class-OpenSSL::ASN1::ASN1Data">
    <h1 id="class-OpenSSL::ASN1::ASN1Data" class="class">
      class OpenSSL::ASN1::ASN1Data
    </h1>

    <section class="description">
    
<p>The top-level class representing any ASN.1 object. When parsed by <a href="../ASN1.html#method-c-decode"><code>ASN1.decode</code></a>, tagged values are always represented by an instance of <a href="ASN1Data.html"><code>ASN1Data</code></a>.</p>

<h2 id="class-OpenSSL::ASN1::ASN1Data-label-The+role+of+ASN1Data+for+parsing+tagged+values">The role of <a href="ASN1Data.html"><code>ASN1Data</code></a> for parsing tagged values<span><a href="#class-OpenSSL::ASN1::ASN1Data-label-The+role+of+ASN1Data+for+parsing+tagged+values">&para;</a> <a href="#top">&uarr;</a></span></h2>

<p>When encoding an ASN.1 type it is inherently clear what original type (e.g. INTEGER, OCTET STRING etc.) this value has, regardless of its tagging. But opposed to the time an ASN.1 type is to be encoded, when parsing them it is not possible to deduce the “real type” of tagged values. This is why tagged values are generally parsed into <a href="ASN1Data.html"><code>ASN1Data</code></a> instances, but with a different outcome for implicit and explicit tagging.</p>

<h3 id="class-OpenSSL::ASN1::ASN1Data-label-Example+of+a+parsed+implicitly+tagged+value">Example of a parsed implicitly tagged value<span><a href="#class-OpenSSL::ASN1::ASN1Data-label-Example+of+a+parsed+implicitly+tagged+value">&para;</a> <a href="#top">&uarr;</a></span></h3>

<p>An implicitly 1-tagged INTEGER value will be parsed as an <a href="ASN1Data.html"><code>ASN1Data</code></a> with</p>
<ul><li>
<p><em>tag</em> equal to 1</p>
</li><li>
<p><em>tag_class</em> equal to <code>:CONTEXT_SPECIFIC</code></p>
</li><li>
<p><em>value</em> equal to a String that carries the raw encoding of the INTEGER.</p>
</li></ul>

<p>This implies that a subsequent decoding step is required to completely decode implicitly tagged values.</p>

<h3 id="class-OpenSSL::ASN1::ASN1Data-label-Example+of+a+parsed+explicitly+tagged+value">Example of a parsed explicitly tagged value<span><a href="#class-OpenSSL::ASN1::ASN1Data-label-Example+of+a+parsed+explicitly+tagged+value">&para;</a> <a href="#top">&uarr;</a></span></h3>

<p>An explicitly 1-tagged INTEGER value will be parsed as an <a href="ASN1Data.html"><code>ASN1Data</code></a> with</p>
<ul><li>
<p><em>tag</em> equal to 1</p>
</li><li>
<p><em>tag_class</em> equal to <code>:CONTEXT_SPECIFIC</code></p>
</li><li>
<p><em>value</em> equal to an Array with one single element, an instance of <a href="../../Integer.html"><code>OpenSSL::ASN1::Integer</code></a>, i.e. the inner element is the non-tagged primitive value, and the tagging is represented in the outer <a href="ASN1Data.html"><code>ASN1Data</code></a></p>
</li></ul>

<h2 id="class-OpenSSL::ASN1::ASN1Data-label-Example+-+Decoding+an+implicitly+tagged+INTEGER">Example - Decoding an implicitly tagged INTEGER<span><a href="#class-OpenSSL::ASN1::ASN1Data-label-Example+-+Decoding+an+implicitly+tagged+INTEGER">&para;</a> <a href="#top">&uarr;</a></span></h2>

<pre class="ruby"><span class="ruby-identifier">int</span> = <span class="ruby-constant">OpenSSL</span><span class="ruby-operator">::</span><span class="ruby-constant">ASN1</span><span class="ruby-operator">::</span><span class="ruby-constant">Integer</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value">1</span>, <span class="ruby-value">0</span>, <span class="ruby-value">:IMPLICIT</span>) <span class="ruby-comment"># implicit 0-tagged</span>
<span class="ruby-identifier">seq</span> = <span class="ruby-constant">OpenSSL</span><span class="ruby-operator">::</span><span class="ruby-constant">ASN1</span><span class="ruby-operator">::</span><span class="ruby-constant">Sequence</span>.<span class="ruby-identifier">new</span>( [<span class="ruby-identifier">int</span>] )
<span class="ruby-identifier">der</span> = <span class="ruby-identifier">seq</span>.<span class="ruby-identifier">to_der</span>
<span class="ruby-identifier">asn1</span> = <span class="ruby-constant">OpenSSL</span><span class="ruby-operator">::</span><span class="ruby-constant">ASN1</span>.<span class="ruby-identifier">decode</span>(<span class="ruby-identifier">der</span>)
<span class="ruby-comment"># pp asn1 =&gt; #&lt;OpenSSL::ASN1::Sequence:0x87326e0</span>
<span class="ruby-comment">#              @indefinite_length=false,</span>
<span class="ruby-comment">#              @tag=16,</span>
<span class="ruby-comment">#              @tag_class=:UNIVERSAL,</span>
<span class="ruby-comment">#              @tagging=nil,</span>
<span class="ruby-comment">#              @value=</span>
<span class="ruby-comment">#                [#&lt;OpenSSL::ASN1::ASN1Data:0x87326f4</span>
<span class="ruby-comment">#                   @indefinite_length=false,</span>
<span class="ruby-comment">#                   @tag=0,</span>
<span class="ruby-comment">#                   @tag_class=:CONTEXT_SPECIFIC,</span>
<span class="ruby-comment">#                   @value=&quot;\x01&quot;&gt;]&gt;</span>
<span class="ruby-identifier">raw_int</span> = <span class="ruby-identifier">asn1</span>.<span class="ruby-identifier">value</span>[<span class="ruby-value">0</span>]
<span class="ruby-comment"># manually rewrite tag and tag class to make it an UNIVERSAL value</span>
<span class="ruby-identifier">raw_int</span>.<span class="ruby-identifier">tag</span> = <span class="ruby-constant">OpenSSL</span><span class="ruby-operator">::</span><span class="ruby-constant">ASN1</span><span class="ruby-operator">::</span><span class="ruby-constant">INTEGER</span>
<span class="ruby-identifier">raw_int</span>.<span class="ruby-identifier">tag_class</span> = <span class="ruby-value">:UNIVERSAL</span>
<span class="ruby-identifier">int2</span> = <span class="ruby-constant">OpenSSL</span><span class="ruby-operator">::</span><span class="ruby-constant">ASN1</span>.<span class="ruby-identifier">decode</span>(<span class="ruby-identifier">raw_int</span>)
<span class="ruby-identifier">puts</span> <span class="ruby-identifier">int2</span>.<span class="ruby-identifier">value</span> <span class="ruby-comment"># =&gt; 1</span>
</pre>

<h2 id="class-OpenSSL::ASN1::ASN1Data-label-Example+-+Decoding+an+explicitly+tagged+INTEGER">Example - Decoding an explicitly tagged INTEGER<span><a href="#class-OpenSSL::ASN1::ASN1Data-label-Example+-+Decoding+an+explicitly+tagged+INTEGER">&para;</a> <a href="#top">&uarr;</a></span></h2>

<pre class="ruby"><span class="ruby-identifier">int</span> = <span class="ruby-constant">OpenSSL</span><span class="ruby-operator">::</span><span class="ruby-constant">ASN1</span><span class="ruby-operator">::</span><span class="ruby-constant">Integer</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value">1</span>, <span class="ruby-value">0</span>, <span class="ruby-value">:EXPLICIT</span>) <span class="ruby-comment"># explicit 0-tagged</span>
<span class="ruby-identifier">seq</span> = <span class="ruby-constant">OpenSSL</span><span class="ruby-operator">::</span><span class="ruby-constant">ASN1</span><span class="ruby-operator">::</span><span class="ruby-constant">Sequence</span>.<span class="ruby-identifier">new</span>( [<span class="ruby-identifier">int</span>] )
<span class="ruby-identifier">der</span> = <span class="ruby-identifier">seq</span>.<span class="ruby-identifier">to_der</span>
<span class="ruby-identifier">asn1</span> = <span class="ruby-constant">OpenSSL</span><span class="ruby-operator">::</span><span class="ruby-constant">ASN1</span>.<span class="ruby-identifier">decode</span>(<span class="ruby-identifier">der</span>)
<span class="ruby-comment"># pp asn1 =&gt; #&lt;OpenSSL::ASN1::Sequence:0x87326e0</span>
<span class="ruby-comment">#              @indefinite_length=false,</span>
<span class="ruby-comment">#              @tag=16,</span>
<span class="ruby-comment">#              @tag_class=:UNIVERSAL,</span>
<span class="ruby-comment">#              @tagging=nil,</span>
<span class="ruby-comment">#              @value=</span>
<span class="ruby-comment">#                [#&lt;OpenSSL::ASN1::ASN1Data:0x87326f4</span>
<span class="ruby-comment">#                   @indefinite_length=false,</span>
<span class="ruby-comment">#                   @tag=0,</span>
<span class="ruby-comment">#                   @tag_class=:CONTEXT_SPECIFIC,</span>
<span class="ruby-comment">#                   @value=</span>
<span class="ruby-comment">#                     [#&lt;OpenSSL::ASN1::Integer:0x85bf308</span>
<span class="ruby-comment">#                        @indefinite_length=false,</span>
<span class="ruby-comment">#                        @tag=2,</span>
<span class="ruby-comment">#                        @tag_class=:UNIVERSAL</span>
<span class="ruby-comment">#                        @tagging=nil,</span>
<span class="ruby-comment">#                        @value=1&gt;]&gt;]&gt;</span>
<span class="ruby-identifier">int2</span> = <span class="ruby-identifier">asn1</span>.<span class="ruby-identifier">value</span>[<span class="ruby-value">0</span>].<span class="ruby-identifier">value</span>[<span class="ruby-value">0</span>]
<span class="ruby-identifier">puts</span> <span class="ruby-identifier">int2</span>.<span class="ruby-identifier">value</span> <span class="ruby-comment"># =&gt; 1</span>
</pre>

    </section>

      <section id="5Buntitled-5D" class="documentation-section">



        <section class="attribute-method-details" class="method-section">
        <header>
        <h3>Attributes</h3>
        </header>

          <div id="attribute-i-indefinite_length" class="method-detail">
            <div class="method-heading attribute-method-heading">
              <span class="method-name">indefinite_length</span><span
                class="attribute-access-type">[RW]</span>
            </div>

            <div class="method-description">
              <p>Never <code>nil</code>. A boolean value indicating whether the encoding uses indefinite length (in the case of parsing) or whether an indefinite length form shall be used (in the encoding case). In DER, every value uses definite length form. But in scenarios where large amounts of data need to be transferred it might be desirable to have some kind of streaming support available. For example, huge OCTET STRINGs are preferably sent in smaller-sized chunks, each at a time. This is possible in BER by setting the length bytes of an encoding to zero and by this indicating that the following value will be sent in chunks. Indefinite length encodings are always constructed. The end of such a stream of chunks is indicated by sending a EOC (End of Content) tag. SETs and SEQUENCEs may use an indefinite length encoding, but also primitive types such as e.g. OCTET STRINGS or BIT STRINGS may leverage this functionality (cf. ITU-T X.690).</p>
              </div>
            </div>
          <div id="attribute-i-infinite_length" class="method-detail">
            <div class="method-heading attribute-method-heading">
              <span class="method-name">infinite_length</span><span
                class="attribute-access-type">[RW]</span>
            </div>

            <div class="method-description">
              <p>Never <code>nil</code>. A boolean value indicating whether the encoding uses indefinite length (in the case of parsing) or whether an indefinite length form shall be used (in the encoding case). In DER, every value uses definite length form. But in scenarios where large amounts of data need to be transferred it might be desirable to have some kind of streaming support available. For example, huge OCTET STRINGs are preferably sent in smaller-sized chunks, each at a time. This is possible in BER by setting the length bytes of an encoding to zero and by this indicating that the following value will be sent in chunks. Indefinite length encodings are always constructed. The end of such a stream of chunks is indicated by sending a EOC (End of Content) tag. SETs and SEQUENCEs may use an indefinite length encoding, but also primitive types such as e.g. OCTET STRINGS or BIT STRINGS may leverage this functionality (cf. ITU-T X.690).</p>
              </div>
            </div>
          <div id="attribute-i-tag" class="method-detail">
            <div class="method-heading attribute-method-heading">
              <span class="method-name">tag</span><span
                class="attribute-access-type">[RW]</span>
            </div>

            <div class="method-description">
              <p>An <a href="../../Integer.html"><code>Integer</code></a> representing the tag number of this <a href="ASN1Data.html"><code>ASN1Data</code></a>. Never <code>nil</code>.</p>
              </div>
            </div>
          <div id="attribute-i-tag_class" class="method-detail">
            <div class="method-heading attribute-method-heading">
              <span class="method-name">tag_class</span><span
                class="attribute-access-type">[RW]</span>
            </div>

            <div class="method-description">
              <p>A Symbol representing the tag class of this <a href="ASN1Data.html"><code>ASN1Data</code></a>. Never <code>nil</code>. See <a href="ASN1Data.html"><code>ASN1Data</code></a> for possible values.</p>
              </div>
            </div>
          <div id="attribute-i-value" class="method-detail">
            <div class="method-heading attribute-method-heading">
              <span class="method-name">value</span><span
                class="attribute-access-type">[RW]</span>
            </div>

            <div class="method-description">
              <p>Carries the value of a ASN.1 type. Please confer <a href="Constructive.html"><code>Constructive</code></a> and <a href="Primitive.html"><code>Primitive</code></a> for the mappings between ASN.1 data types and Ruby classes.</p>
              </div>
            </div>
            </section>


                <section id="public-class-5Buntitled-5D-method-details" class="method-section">
                <header>
                <h3>Public Class Methods</h3>
                </header>

                  <div id="method-c-new" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          OpenSSL::ASN1::ASN1Data.new(value, tag, tag_class) &rarr; ASN1Data
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p><em>value</em>: Please have a look at <a href="Constructive.html"><code>Constructive</code></a> and <a href="Primitive.html"><code>Primitive</code></a> to see how Ruby types are mapped to ASN.1 types and vice versa.</p>

<p><em>tag</em>: An <a href="../../Integer.html"><code>Integer</code></a> indicating the tag number.</p>

<p><em>tag_class</em>: A Symbol indicating the tag class. Please cf. <a href="../ASN1.html"><code>ASN1</code></a> for possible values.</p>

<h2 id="method-c-new-label-Example">Example<span><a href="#method-c-new-label-Example">&para;</a> <a href="#top">&uarr;</a></span></h2>

<pre class="ruby"><span class="ruby-identifier">asn1_int</span> = <span class="ruby-constant">OpenSSL</span><span class="ruby-operator">::</span><span class="ruby-constant">ASN1Data</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value">42</span>, <span class="ruby-value">2</span>, <span class="ruby-value">:UNIVERSAL</span>) <span class="ruby-comment"># =&gt; Same as OpenSSL::ASN1::Integer.new(42)</span>
<span class="ruby-identifier">tagged_int</span> = <span class="ruby-constant">OpenSSL</span><span class="ruby-operator">::</span><span class="ruby-constant">ASN1Data</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value">42</span>, <span class="ruby-value">0</span>, <span class="ruby-value">:CONTEXT_SPECIFIC</span>) <span class="ruby-comment"># implicitly 0-tagged INTEGER</span>
</pre>

                              <div class="method-source-code" id="new-source">
            <pre>static VALUE
ossl_asn1data_initialize(VALUE self, VALUE value, VALUE tag, VALUE tag_class)
{
    if(!SYMBOL_P(tag_class))
        ossl_raise(eASN1Error, &quot;invalid tag class&quot;);
    ossl_asn1_set_tag(self, tag);
    ossl_asn1_set_value(self, value);
    ossl_asn1_set_tag_class(self, tag_class);
    ossl_asn1_set_indefinite_length(self, Qfalse);

    return self;
}</pre>
                              </div>
                            </div>


                          </div>

                          </section>

                <section id="public-instance-5Buntitled-5D-method-details" class="method-section">
                <header>
                <h3>Public Instance Methods</h3>
                </header>

                  <div id="method-i-to_der" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          to_der &rarr; DER-encoded String
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Encodes this <a href="ASN1Data.html"><code>ASN1Data</code></a> into a DER-encoded String value. The result is DER-encoded except for the possibility of indefinite length forms. Indefinite length forms are not allowed in strict DER, so strictly speaking the result of such an encoding would be a BER-encoding.</p>

                              <div class="method-source-code" id="to_der-source">
            <pre>static VALUE
ossl_asn1data_to_der(VALUE self)
{
    VALUE value = ossl_asn1_get_value(self);

    if (rb_obj_is_kind_of(value, rb_cArray))
        return ossl_asn1cons_to_der(self);
    else {
        if (RTEST(ossl_asn1_get_indefinite_length(self)))
            ossl_raise(eASN1Error, &quot;indefinite length form cannot be used &quot; \
                       &quot;with primitive encoding&quot;);
        return ossl_asn1prim_to_der(self);
    }
}</pre>
                              </div>
                            </div>


                          </div>

                          </section>

              </section>
              </main>



            </div>  <!--  class='wrapper hdiv' -->


<footer id="validator-badges" role="contentinfo">
<p><a href="https://validator.w3.org/check/referer">Validate</a></p>
<p>Generated by <a href="https://ruby.github.io/rdoc/">RDoc</a> 6.4.0.</p>
<p>Based on <a href="https://github.com/ged/darkfish/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.</p>

  
    <p><p><a href="https://ruby-doc.org">Ruby-doc.org</a> is a service of <a href="https://jamesbritt.com">James Britt</a> and <a href="https://neurogami.com">Neurogami</a>, purveyors of fine <a href='https://jamesbritt.bandcamp.com/'>dance noise</a></p>
</p>
  
  </footer>

<script type="text/javascript">


  let ads  = $("#carbonads-container").children().detach();


  function swapMode() {
    var cookieName = 'darkmode';
    var cssDarkmode = Cookies.get(cookieName);
    console.log("***** swapMode! " + cssDarkmode + " *****");


    if (cssDarkmode == "true") {
      console.log("We have dark mode, set the css to light ...");
      $('#rdoccss').attr("href", defaultModeCssHref);
      $('#cssSelect').text("Dark mode");
      cssDarkmode = "false";
      console.log("swapMode! Now set cookie to " + cssDarkmode);
      Cookies.set(cookieName, cssDarkmode);

    } else {
      console.log("We not have dark mode, set the css to dark ...");
      $('#rdoccss').attr("href", darkModeCsseHref);
      $('#cssSelect').text("Light mode");
      cssDarkmode = "true";
      console.log("swapMode! Now set cookie to " + cssDarkmode);
      Cookies.set(cookieName, cssDarkmode);

    }

    console.log("  --------------- ");
  }


const vueCssApp = new Vue({
el: '#menubar',
data: {
isDark: false
},
methods: {
toggleClass: function(event){
this.isDark = !this.isDark;
}
}
})

const vueApp = new Vue({
el: '#vapp',
data: { 
isOpen: true
},

mounted() {
this.handleResize();
this.manage_mob_classes();
window.addEventListener('resize', this.handleResize)
//this.isOpen !=  (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent));
},
destroyed() {
window.removeEventListener('resize', this.handleResize)
},
created() {
//manage_mob_classes();
},

methods : {
isMobile() {
  return (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent));
},

  handleResize() {
    if (!this.isMobile()) {
      this.isOpen = window.innerWidth > 800;
    }
  },

  manage_mob_classes() {
    if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) {
      $("nav").addClass("mob_nav");
      $("main").addClass("mob_main");
      $("#extraz").addClass("mob_extraz");
      $("#carbonads-container").addClass("mob_carbonads-container");
      this.isOpen  = false;
    } else {
      $("nav").removeClass("mob_nav") 
        $("main").removeClass("mob_main");
      $("#extraz").removeClass("mob_extraz");
      $("#carbonads-container").removeClass("mob_carbonads-container");
      this.isOpen  = true;
    }
  },

  toggleNav() {
    this.isOpen =! this.isOpen ;
    // alert("Toggle nav!");
    console.log("toggleNav() click: " + this.isOpen );
  }
}
})

$("#carbonads-container").append(ads);


$(function() {

    var darkmode = Cookies.get("darkmode");
    console.log("Document ready: " + darkmode);

    if ( darkmode  == "true" ) {
      $('#cssSelect').text("Light mode");
    } else {
      $('#cssSelect').text("Dark mode");
     }

    $('body').css('display','block');
    });

</script>

    
  </body> 
</html>

